package pkg

import (
	"fmt"
	"strconv"
	"time"
)

func DisposeTime(timeNow time.Time) string {

	var disTime string
	var number int

	times := time.Now().Sub(timeNow)

	hours := times.Hours()

	i := int(hours)

	fmt.Println(i)

	if i%24 == 0 && i != 0 {

		hour := i / 24
		if hour == 0 {
			number = 1
		} else {
			number = hour
		}
		disTime = strconv.Itoa(number) + "天前发布"
	} else if i < 24 {
		if i < 1 {
			minute := fmt.Sprintf("%.2f", times.Minutes())
			disTime = minute + "分钟前发布"
		} else {
			number = i
			disTime = strconv.Itoa(number) + "小时前发布"
		}
	}
	return disTime
}
